<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>修改密码</title>
<link rel="stylesheet" href="${s.base}/res/layui/css/layui.css"
	media="all" />
<link rel="stylesheet" href="${s.base}/res/css/public.css" media="all" />
</head>
<body class="childrenBody">
	<form class="layui-form layui-row changePwd">
		<div class="layui-col-xs12 layui-col-sm6 layui-col-md6">
			<div class="layui-form-item">
				<label class="layui-form-label">旧密码</label>
				<div class="layui-input-block">
					<input id="oldPwd" type="password" value="" placeholder="请输入旧密码"
						lay-verify="required" class="layui-input pwd">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">新密码</label>
				<div class="layui-input-block">
					<input type="password" value="" placeholder="请输入新密码"
						lay-verify="required" id="newPwd" class="layui-input pwd">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">确认密码</label>
				<div class="layui-input-block">
					<input type="password" value="" placeholder="请确认密码"
						lay-verify="required" id="reNewPwd" class="layui-input pwd">
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit="" lay-filter="changePwd">立即修改</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</div>
	</form>
	<script type="text/javascript" src="${s.base}/res/layui/layui.js"></script>
	<script type="text/javascript" src="${s.base}/res/js/md5.js"></script>
	<script type="text/javascript">
		layui
				.use(
						[ 'form', 'layer' ],
						function() {
							var form = layui.form, layer = parent.layer === undefined ? layui.layer
									: top.layer, $ = layui.jquery;

							form.on("submit(changePwd)", function(data) {
								var oldPwd = $("#oldPwd").val();
								var newPwd = $("#newPwd").val();
								var reNewPwd = $("#reNewPwd").val();
								if (reNewPwd != newPwd) {
									layer.msg("两次密码不一致！", {
										icon : 5,
										time : 1000
									});
									return false;
								}
								//弹出loading
								var index = top.layer.msg('数据提交中，请稍候', {
									icon : 16,
									time : false,
									shade : 0.8
								});
								$.ajax({
									type : 'post',
									url : '/pswd/setting.html',
									data : {
										oldPswd : hex_md5(oldPwd),
										newPswd : hex_md5(newPwd)
									},
									timeout : 2000,
									success : function(msg) {
										top.layer.close(index);
										if (msg == true) {
											top.layer.msg("修改成功！");
										} else {
											layer.msg(msg, {
												icon : 5,
												time : 1000
											});
										}
										layer.closeAll("iframe");
									},
									error : function() {
										layer.msg("操作失败！", {
											icon : 5,
											time : 1000
										});
										layer.close(index);
									}
								});
								return false;
							});

						});
	</script>
</body>
</html>